package com.usian.comment.controller;

import com.usian.api.comment.ApCommentControllerApi;
import com.usian.comment.service.CommentService;
import com.usian.model.comment.dtos.CommentDto;
import com.usian.model.comment.dtos.CommentLikeDto;
import com.usian.model.comment.dtos.CommentSaveDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Auther:ASS
 * @Date:2023/3/6 16:21
 */
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController implements ApCommentControllerApi {



    @Autowired
    private CommentService commentService;


    /**
     * 保存评论
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("saveComment/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return commentService.saveComment(dto);
    }



    /**
     * 点赞某一条评论
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {

        return commentService.like(dto);
    }

    /**
     * 查询评论
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load")
    public ResponseResult findByArticleId(@RequestBody CommentDto dto) {
        return commentService.findByArticleId(dto);
    }
}
